package com.hexinfo.dmpro.dev.data.transfer.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.dev.data.transfer.model.DesensitizeFieldFilter;
import com.hexinfo.dmpro.dev.data.transfer.service.IDesensitizeFieldFilterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/api/desensitize/field/filter")
@Api(value = "desensitizeFieldFilter", tags = "脱敏字段黑名单管理")
public class DesensitizeFieldFilterController {

    private final IDesensitizeFieldFilterService desensitizeFieldFilterService;

    /**
     * @Method getDesensitizeFieldFilter
     * @Param
     * @param page
     * @param desensitizeFieldFilter
     * @Return org.springframework.http.ResponseEntity<java.lang.Object>
     * @Description 分页查询
     * @Author Wang zhihao
     * @Date 2024/1/8 9:38
     * @Version V1.0
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public ResponseEntity<Object> getDesensitizeFieldFilter(Page page, DesensitizeFieldFilter desensitizeFieldFilter) {
        return ResponseEntity.ok(desensitizeFieldFilterService.queryList(page, desensitizeFieldFilter));
    }

    @ApiOperation(value = "新增脱敏字段黑名单", notes = "新增脱敏字段黑名单")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody DesensitizeFieldFilter desensitizeFieldFilter) {
        desensitizeFieldFilterService.save(desensitizeFieldFilter);
        return ResponseEntity.ok(true);
    }

    @ApiOperation(value = "通过id删除脱敏字段黑名单", notes = "通过id删除脱敏字段黑名单")
    @DeleteMapping("/{ids}")
    public ResponseEntity<Object> removeByIds(@PathVariable("ids") @NotNull List<String> ids) {
        return ResponseEntity.ok(desensitizeFieldFilterService.removeByIds(ids));
    }
}
